
package com.apes.fn.crm.ReturnVisit.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.fn.crm.customerExpand.FnCustomerExpand;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

/**
 * 售后回访单明细
 *
 * @author bbyford
 * @create 2020-2-5
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ReturnVisitItem.CONST_TABLE_NAME)
public class ReturnVisitItem extends BaseModel {
    public static final String CONST_TABLE_NAME = "fn_return_visit_item";

    @Id
    @Comment("编码")
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = "fn_return_visit_item", name = "售后回访单明细")
    private String id;

    @NotNull
    @Comment("回访单号")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "return_visit_id", referencedColumnName = "id", nullable=false)
    private ReturnVisit returnVisit;

    @Comment("公司")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id", nullable = false)
    private PartyRole company;

    @Comment("会员扩展信息")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "customer_expand_id", referencedColumnName = "id")
    private FnCustomerExpand customerExpand;

    @Column(name = "source", length = 32)
    @Comment("来源单号")
    private String source;

    @Column(name = "source_business_type", length = 32)
    @Comment("来源单据类型")
    private String sourceBusinessType;

    @Column(name = "source_business_type_name", length = 64)
    @Comment("来源单据类型名称")
    private String sourceBusinessTypeName;

    @Comment("消费日期")
    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "consume_date", nullable = false)
    private Date consumeDate;
}


